package com.cloudlead.common.worker.desc.datatype;

import java.util.LinkedHashMap;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonTypeName;

@JsonTypeName("map")
public class MapData extends ComplexData {
    protected Map<String, FormData> mapping;

    public Map<String, FormData> getMapping() {
        return mapping;
    }

    public void setMapping(Map<String, FormData> mapping) {
        this.mapping = mapping;
    }

    @Override
    public Object clone() throws CloneNotSupportedException {
        if (null == this) {
            return null;
        }
        MapData clone = (MapData) super.clone();
        if (null != mapping) {
            Map<String, FormData> cloneMapping = new LinkedHashMap<>();
            for (Map.Entry<String, FormData> entry : this.mapping.entrySet()) {
                cloneMapping.put(entry.getKey(), (FormData) entry.getValue().clone());
            }
            clone.mapping = cloneMapping;
        }
        return clone;
    }
}
